<@app.html>
    <@app.head>
    <script>
        $(function () {
            $('#page_table').datagrid({
                fit: true,
                width: '100%',
                height: '100%',
                striped: true,
                pagination: true,
                url: "${contextPath}/security/hdw/bicycle/page.htm",
                fitColumns: true,
                pageSize: 10,
                pageList: [10, 50, 100],
                idField: 'id',
                singleSelect: true,
                selectOnCheck: false,
                checkOnSelect: false,
                autoRowHeight: false,
                rowStyler: gridRowStyler,
                columns: [
                    [
                        {
                            title: '车牌',
                            align: 'center',
                            field: 'bicycleId',
                            width: 60,
                            formatter: function (val, row) {
                                return row.id;
                            }
                        },
                        {
                            title: '客户名称',
                            align: 'center',
                            field: 'customerName',
                            width: 60
                        },
                        {
                            title: '客户手机',
                            align: 'center',
                            field: 'customerMobile',
                            width: 60
                        },
                        {
                            title: '当前使用电池',
                            align: 'center',
                            field: 'batteryId',
                            width: 60
                        },
                        {
                            title: '单次行驶距离(米)',
                            align: 'center',
                            field: 'mileage',
                            width: 60
                        },
                        {
                            title: '总行驶距离(米)',
                            align: 'center',
                            field: 'totalMileage',
                            width: 60
                        },
                        {
                            title: '对应订单',
                            align: 'center',
                            field: 'orderId',
                            width: 60
                        },
                        {
                            title: '创建时间',
                            align: 'center',
                            field: 'createTime',
                            width: 60
                        },
                        {
                            title: '操作',
                            align: 'center',
                            field: 'id',
                            width: 60,
                            formatter: function (val, row) {
                                <@app.has_oper oper_code='3_5_2'>
                                    var html = ' <a href="javascript:remove(\'ID\')">删除</a>';
                                </@app.has_oper>
                                <@app.has_oper oper_code='3_5_3'>
                                    html += ' <a href="javascript:bicycle_location(\'ID\')">轨迹</a>'
                                </@app.has_oper>
                                return html.replace(/ID/g, row.id);
                            }
                        }
                    ]
                ],
                onLoadSuccess: function () {
                    $('#page_table').datagrid('clearChecked');
                    $('#page_table').datagrid('clearSelections');
                }
            });
        })
        function reload() {
            var datagrid = $('#page_table');
            datagrid.datagrid('reload');
        }

        function query() {
            $('#page_table').datagrid('options').queryParams = {
                id: $('#bicycleId').val(),
                customerMobile: $('#customerMobile').val()
            };
            $('#page_table').datagrid('load');
        }

        function remove(id) {
            $.messager.confirm('提示信息', '确认删除?', function (ok) {
                if (ok) {
                    $.post("${contextPath}/security/hdw/bicycle/delete.htm?id=" + id, function (json) {
                        if (json.success == 1) {
                            $.messager.alert('提示消息', '操作成功', 'info');
                            reload();
                        } else {
                            $.messager.alert('提示消息', json.message, 'info');
                        }
                    }, 'json');
                }
            });
        }
        function bicycle_location(id) {
            App.dialog.show({
                css: 'width:1200px;height:760px;',
                title: '电动车轨迹',
                href: "${contextPath}/security/hdw/bicycle/bicycle_location.htm?id=" + id,
                event: {}
            });
        }
        function view(id) {
            App.dialog.show({
                css: 'width:560px;height:280px;',
                title: '查看',
                href: "${contextPath}/security/hdw/bicycle/view.htm?id=" + id
            });
        }
    </script>
    </@app.head>

    <@app.body>

        <@app.container>
            <@app.banner/>

        <div class="main">
            <@app.menu/>

            <div class="content">
                <div class="panel search">
                    <div class="float_right">
                        <button class="btn btn_yellow" onclick="query()">搜索</button>
                    </div>
                    <table cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td width="80" align="right">车牌：</td>
                            <td><input type="text" class="text" id="bicycleId"/></td>
                            <td width="80" align="right">客户手机号：</td>
                            <td><input type="text" class="text" id="customerMobile"/></td>
                        </tr>
                    </table>
                </div>
                <div class="panel grid_wrap">
                    <div class="toolbar clearfix">
                        <h3>电动车</h3>
                    </div>
                    <div class="grid">
                        <table id="page_table"></table>
                    </div>
                </div>
            </div>
        </div>
        </@app.container>
    </@app.body>
</@app.html>
